package com.kly.user.db.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.google.common.collect.Maps;
import com.kly.user.db.dao.UserProfileDao;
import com.kly.user.db.entity.UserProfileEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: yujianfu
 * Date: 2023-05-22
 * Time: 10:46:07.414
 */
@Repository
public class UserProfileDaoImpl extends AbstractBaseMapper<UserProfileEntity> implements UserProfileDao {

    /**
     * @param params 查询用户参数
     * @return
     */
    @Override
    public List<UserProfileEntity> queryUsers(Map<String, Object> params) {
        return this.getSqlSession().selectList(this.getStatement("queryUsers"), params);
    }

    @Override
    public List<UserProfileEntity> getList(List<String> userCodes, Integer type) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCodes", userCodes);
        params.put("type", type);
        return this.getSqlSession().selectList(this.getStatement("getList"), params);
    }


    @Override
    public UserProfileEntity queryUsersByUserCode(String userCode) {
        return this.getSqlSession().selectOne(this.getStatement("queryUsersByUserCode"), userCode);
    }

    @Override
    public UserProfileEntity queryUsersByUserCodeAndType(String userCode, Integer userProfileType) {
        final HashMap<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("userProfileType", userProfileType);
        return this.getSqlSession().selectOne(this.getStatement("queryUsersByUserCodeAndType"), params);
    }

}